package com.abel.roommanager.controller;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.abel.roommanager.pojo.Clazz;
import com.abel.roommanager.service.ClazzService;
import com.abel.roommanager.util.Page;
@Controller
@RequestMapping("/cla")
@Scope("prototype")
public class ClazzController {
	@Resource
	private ClazzService clazzService;
	@RequestMapping("findAll")
   public String findAllClass(Model model,int curPage) {
		Page<Clazz> pages= clazzService.findAllClasses(curPage);
		model.addAttribute("pages", pages);
	    return "/jsp/class.jsp";
    }
	@RequestMapping("/add")
	@ResponseBody
	public int addClass(String cname,String time,int tid) {
		return clazzService.addClass(cname,time,tid);
	}
	@RequestMapping("/del")
	@ResponseBody
	public int delClassByCid(int cid) {
		return clazzService.delClassByCid(cid);	
	}
	@RequestMapping("/findClasses")
	@ResponseBody
	public List<Clazz> findClasses(){
		
		return clazzService.findClasses();
		
	}
}
